﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Principal.master" AutoEventWireup="true" CodeFile="Perfiles.aspx.cs" Inherits="Perfiles" %>

<%@ Register src="MenusDePagina/WebUserControlMenuConfiguracion.ascx" tagname="WebUserControlMenuConfiguracion" tagprefix="uc1" %>

<%@ Register src="MenusDePagina/WebUserControlMenuUsuarios.ascx" tagname="WebUserControlMenuUsuarios" tagprefix="uc2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMenuDePagina" Runat="Server">
    <uc2:WebUserControlMenuUsuarios ID="WebUserControlMenuUsuarios1" 
        runat="server" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderPrincipal" Runat="Server">
    <asp:Panel ID="PanelMessage" runat="server" HorizontalAlign="Center">
        <asp:Label ID="LabelEntrada" runat="server" style="text-align: center"></asp:Label>
    </asp:Panel>
    <asp:FormView ID="FormViewPerfil" runat="server" DataKeyNames="Codigo" 
        DataSourceID="ObjectDataSourcePerfiles" DefaultMode="Insert" 
        oniteminserted="FormViewPerfil_ItemInserted" Visible="False" 
        HorizontalAlign="Center">
        <InsertItemTemplate>
            <table class="detalle">
                <thead>
                <tr>
                    <th colspan="2" align="center">Adicionar</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        Nombre:
                    </td>
                    <td>
                        <asp:TextBox ID="NombreTextBox" runat="server" Text='<%# Bind("Nombre") %>' 
                            MaxLength="50" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorNombre" runat="server" 
                            ControlToValidate="NombreTextBox" ErrorMessage="El nombre es obligatorio" 
                            ValidationGroup="Validadores">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Peso:
                    </td>
                    <td>
                        <asp:TextBox ID="PesoTextBox" runat="server" Text='<%# Bind("Peso") %>' 
                            MaxLength="20" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPeso" runat="server" 
                            ControlToValidate="PesoTextBox" ErrorMessage="El peso es obligatorio" 
                            ValidationGroup="Validadores">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="2">
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                            CommandName="Insert" Text="Insert" ValidationGroup="Validadores" />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" 
                            onclick="InsertCancelButton_Click" Text="Cancel" />
                    </td>
                </tr>
                </tfoot>
            </table>
        </InsertItemTemplate>
    </asp:FormView>
    <asp:GridView ID="GridViewPerfiles" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" CssClass="detalle" 
        DataKeyNames="Codigo" DataSourceID="ObjectDataSourcePerfiles" 
        ForeColor="#333333" GridLines="None" HorizontalAlign="Center" 
        onselectedindexchanged="GridViewPerfiles_SelectedIndexChanged">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Update"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <HeaderTemplate>
                    <asp:LinkButton ID="LinkButtonAddNew" runat="server" 
                        onclick="LinkButtonAddNew_Click">Add new</asp:LinkButton>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" 
                        CommandName="Select" Text="Select"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Edit"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete" OnClientClick="javascript:return ConfirmDel(this);"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Codigo" HeaderText="Codigo" 
                SortExpression="Codigo" ReadOnly="True" />
            <asp:BoundField DataField="Nombre" HeaderText="Nombre" 
                SortExpression="Nombre" />
            <asp:BoundField DataField="Peso" HeaderText="Peso" SortExpression="Peso" />
        </Columns>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <EmptyDataTemplate>
            No hay datos asociados a perfiles<br />
            <br />
            <asp:LinkButton ID="LinkButtonAddNew" runat="server" 
                onclick="LinkButtonAddNew_Click">Add new</asp:LinkButton>
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:GridView ID="GridViewUsuariosDelPerfil" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" CssClass="detalle" 
        DataKeyNames="Perfil,Persona" DataSourceID="ObjectDataSourceUsuariosDePerfil" 
        ForeColor="#333333" GridLines="None" HorizontalAlign="Center" 
        Visible="False">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" />
            <asp:TemplateField HeaderText="Persona" SortExpression="Persona">
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList" runat="server" 
                        DataSourceID="ObjectDataSourceUsuarios" DataTextField="Nombre" 
                        DataValueField="Clave" Enabled="False" SelectedValue='<%# Eval("Persona") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <EmptyDataTemplate>
            No hay usuarios asociados al perfil
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSourceUsuariosDePerfil" runat="server" 
        DeleteMethod="eliminarPerfilDeUsuario" InsertMethod="asociarPerfilAUsuario" 
        SelectMethod="consultarUsuariosDePerfil" 
        TypeName="Libreria.RFID.Negocio.PerfilesDeUsuarioNegocio">
        <DeleteParameters>
            <asp:Parameter Name="Perfil" Type="Int32" />
            <asp:Parameter Name="Persona" Type="Int32" />
            <asp:Parameter Name="CadenaDeConexion" Type="String" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridViewPerfiles" Name="perfil" 
                PropertyName="SelectedValue" Type="Int32" />
            <asp:SessionParameter Name="CadenaDeConexion" SessionField="CadenaDeConexion" 
                Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="Perfil" Type="Int32" />
            <asp:Parameter Name="Persona" Type="Int32" />
            <asp:Parameter Name="CadenaDeConexion" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSourcePerfiles" runat="server" 
        DeleteMethod="eliminarPerfil" InsertMethod="crearPerfil" 
        SelectMethod="consultarPerfiles" TypeName="Libreria.RFID.Negocio.PerfilNegocio" 
        UpdateMethod="actualizarPerfil" 
        ondeleted="ObjectDataSourcePerfiles_Deleted">
        <DeleteParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="CadenaDeConexion" Type="String" />
            <asp:Parameter Direction="Output" Name="mensaje" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="Nombre" Type="String" />
            <asp:Parameter Name="Peso" Type="Int32" />
            <asp:Parameter Name="CadenaDeConexion" Type="String" />
        </UpdateParameters>
        <SelectParameters>
            <asp:SessionParameter Name="CadenaDeConexion" SessionField="CadenaDeConexion" 
                Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="Nombre" Type="String" />
            <asp:Parameter Name="Peso" Type="Int32" />
            <asp:Parameter Name="CadenaDeConexion" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSourceUsuarios" runat="server" 
        SelectMethod="consultarUsuarios" 
        TypeName="Libreria.RFID.Negocio.UsuarioNegocio">
        <SelectParameters>
            <asp:SessionParameter Name="CadenaDeConexion" SessionField="CadenaDeConexion" 
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>

